﻿@model ArivisTests.Models.TestCase
@using ArivisTests.Views;
@{
    // get list of active users and test results
    IEnumerable<ArivisTests.Models.UserProfile> users = ViewBag.Users as IEnumerable<ArivisTests.Models.UserProfile>;
    IEnumerable<ArivisTests.Models.TestResult> results = ViewBag.Results as IEnumerable<ArivisTests.Models.TestResult>;
    // load from db context if not defined
    if (users == null || results == null)
    {
        using (var db = new ArivisTests.Models.ArivisTestsDBContext())
        {
            users = users ?? db.ActiveTester.ToList();
            results = results ?? db.TestResults.ToList();
        }
    }
    // make sure the current user is part of dbUsers
    if (Model.User != null && !users.Contains(Model.User))
    {
        var list = users.ToList();
        list.Insert(0, Model.User);
        users = list;
    }
}

<table class="editor-table">
    <tr>
        <td class="editor-label">
            @Html.LabelFor(model => model.Scenario.Url)
        </td>
        <td class="editor-field">
            @Html.DisplayFor(model => model.Scenario.Url)
        </td>
    </tr>
    <tr>
        <td class="editor-label">
            @Html.LabelFor(model => model.Scenario.Duration)
        </td>
        <td class="editor-field">
            @Html.DisplayFor(model => model.Scenario.Duration) min
        </td>
    </tr>
    <tr>
        <td class="editor-label">
            @Html.LabelFor(model => model.Comment)
        </td>
        <td class="editor-field">
            @Html.EditorFor(model => model.Comment)
            @Html.ValidationMessageFor(model => model.Comment)
        </td>
    </tr>
    <tr>
        <td class="editor-label">
            @Html.LabelFor(model => model.Tickets)
        </td>
        <td class="editor-field">
            @Html.EditorFor(model => model.Tickets)
            @Html.ValidationMessageFor(model => model.Tickets)
        </td>
    </tr>
    <tr>
        <td class="editor-label">
            @Html.LabelFor(model => model.User)
        </td>
        <td class="editor-field">
            @Html.UserDropDownList("selectedUser", users, Model.User)
        </td>
    </tr>
    <tr>
        <td class="editor-label">
            @Html.LabelFor(model => model.Result)
        </td>
        <td class="editor-field">
            @Html.TestItemDropDownList("selectedResult", results, Model.Result)
        </td>
    </tr>
</table>
